package com.qm.network;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author wb
 * @date 2023-06-16 14:43
 * @description:
 */
public class SocketClient {
    public static void main(String[] args) throws IOException {
        System.out.println("服务启动");
        // 创建服务端ServerSocket
        // 绑定在某一个端口上
        ServerSocket server = new ServerSocket(10086);
        // 监听端口（堵塞，等待他人连接）
        Socket socket = server.accept();
        // 获取收到的资源
        InputStream inputStream = socket.getInputStream();
        byte[] buf = new byte[1024 * 1024];
        int len;
        while((len = inputStream.read(buf)) != -1){
            System.out.println(new String(buf, 0, len));
        }

        inputStream.close();
        socket.close();


    }
}
